package bavaria.hightech.testit;

import java.lang.reflect.Proxy;

import bavaria.hightech.banking.Account;
import bavaria.hightech.banking.BankImpl;
import bavaria.hightech.banking.ECurrency;
import bavaria.hightech.banking.IBankClientView;
import bavaria.hightech.banking.Money;
import bavaria.hightech.proxy.LoggingHandler;
import bavaria.hightech.timer.InternalClock;

public class ProxyLoggingTest {
	private static InternalClock timer;

	//VM Arguments: -Djava.util.logging.config.file=./src/logger.properties
	public static void main(String[] args) throws Exception{
		timer = InternalClock.getInstance();
		IBankClientView bankImpl = new BankImpl("de", "de");
		LoggingHandler loggingHandler = new LoggingHandler(bankImpl);
		IBankClientView proxy = (IBankClientView) Proxy.newProxyInstance(IBankClientView.class.getClassLoader(), 
				new Class[]{IBankClientView.class}, loggingHandler);
		testit(proxy);
		
	}
	private static void testit(IBankClientView bank) throws Exception{
		
		Account a = bank.openCurrentAccount("DER ADLER");
		bank.cashInValue(a.getAccountNumber(), new Money(2000, ECurrency.EUR), "Wir zahlen auf a Geld ein");
		Account b = bank.openLoanAccount("DER FUSS", 3);
		bank.cashInValue(b.getAccountNumber(), new Money(2000, ECurrency.EUR), "Wir zahlen auf b Geld ein");
	}
}
